package com.zxjbyte.yiyi.framework.mybatis.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import com.zxjbyte.yiyi.framework.common.domain.api.PageQuery;
import com.zxjbyte.yiyi.framework.mybatis.base.BasePO;
import com.zxjbyte.yiyi.framework.mybatis.mapper.BaseMapperX;
import com.zxjbyte.yiyi.framework.mybatis.service.BaseServiceX;
import com.zxjbyte.yiyi.framework.mybatis.util.Condition;

/**
 * 扩展  MyBatis Plus 的ServiceImpl
 * @Author zhangxingjia
 * @Date 2023/3/2 17:42
 * @Version: 1.0
 */
public class BaseServiceXImpl<M extends BaseMapperX<T>, T extends BasePO> extends ServiceImpl<M, T> implements BaseServiceX<T> {


    @Override
    public boolean saveIgnore(T entity) {
        return SqlHelper.retBool(baseMapper.insertIgnore(entity));
    }

    @Override
    public boolean saveReplace(T entity) {
        return SqlHelper.retBool(baseMapper.replace(entity));
    }

    protected IPage<T> getPage(PageQuery query){
        return Condition.getPage(query);
    }

    protected IPage<T> getSimplePage(){
        return Condition.getSimplePage();
    }
}
